package cn.xm.lingshi.controller;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

public class PropertiesConfig implements ServletContextListener {
	//保存加载配置参数
	private static Map<String,String> aliPropertiesMaps =new HashMap<String,String>();
	/*获取配置参数值*/
	public static String getValue(String key){
		return aliPropertiesMaps.get(key);
	}
	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		
		try {
			Properties prop = new Properties();
			InputStream is = this.getClass().getClassLoader().getResourceAsStream("alipay.properties");
			prop.load(is);
			for (String key : prop.stringPropertyNames()) {
				aliPropertiesMaps.put(key, (String) prop.get(key));
			}
			is.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	
		
	}

}
